﻿using PlayingCards.Model.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;

namespace PlayingCards.Repository.BaseRepository
{
    /// <summary>
    ///  Suger仓储
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class BaseRepository<T> : SimpleClient<T> where T : class, new()
    {
        public BaseRepository(ISqlSugarClient db)
        {
            base.Context = db;
        }
        public SqlSugarClient Db;

        public void ExecuteInTransaction(List<T> listObj)
        {
            base.Context.Ado.BeginTran();
            //int res = 0;
            try
            {
                int res = Context.Insertable(listObj).ExecuteCommand();

                Context.Ado.CommitTran();

            }
            catch (Exception)
            {
                Context.Ado.RollbackTran();
            }
        }

    }
}
